<?php

        if (!file_exists("./config.php")) {
            header("Location: install.php");
            die;
        }

        include("./global_conf.php");
        require_once("./config.php");
        require_once($site->includedir."/top_foot.inc.php");
        require_once($site->classdir."/DBmanager.php");
        require_once($site->libdir."/lib.php");
        require_once("./admin/admin_lib.php");
        require_once($site->langdir."/ita.lang.php");

        $mobile=detect_mobile();
        $attr_names=get_attributes_property("full_name");
        $attr_types=get_attributes_property("type");
        if (isset($_GET['n'])) {
            $node=DBmanager::getInstance()->get_node($_GET['n']);
            print_header(!is_null($node['content_type'])?$node['content_type']:"core");
        }
        else {
            print_header("null");
            echo "Nessun nodo indicato";
        }

        if (isset ($node)) {
            if ($node['published']) {
                $author=$node['author'];
                $date_inserted=$node['inserted'];
                unset($node['inserted'], $node['author'], $node['published']);
                echo "<div id=\"content\">";
                foreach ($node as $attr_name => $value) {
                   echo "<div class=\"post ".$attr_name."\">";
                   if (isset($attr_names[$attr_name]))
                       $title=$attr_names[$attr_name];
                   else if (isset($_LANG[$attr_name]))
                       $title=$_LANG[$attr_name];
                   echo "<h3 class=\"title\">".$title."</h3>\n";
                   if (isset($attr_types[$attr_name]) && strcmp($attr_types[$attr_name], "video") == 0)
                              echo "<iframe class=\"youtube-player\"
                                        type=\"text/html\" width=\"480\" height=\"385\"
                                        src=\"http://www.youtube.com/embed/".get_youtube_video_id($value)."\"
                                        frameborder=\"0\">
                                    </iframe>";
                   else if (isset($attr_types[$attr_name]) && strcmp($attr_types[$attr_name], "image") == 0)
                              echo "<img src=\"".$value."\" />";
                   else
                       echo "<div class=\"entry\">".$value."</div>\n";
                   echo "</div>\n";
                }
                echo "<div class=\"right-bottom\"><h4>Creato da <span>".get_author_by_id($author)."</span>il<span>".$date_inserted."</span></h4></div>";
                echo "</div><div style=\"clear: both\">&nbsp;</div>\n";
            }
        }
?>
<?php
        print_footer();
?>